<?php
/**
 * @version $Id: component.php 5173 2006-09-25 18:12:39Z Jinx $
 * @package Joomla
 * @subpackage Config
 * @copyright Copyright (C) 2005 - 2006 Open Source Matters. All rights reserved.
 * @license GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant to the
 * GNU General Public License, and as distributed it includes or is derivative
 * of works licensed under the GNU General Public License or other free or open
 * source software licenses. See COPYRIGHT.php for copyright notices and
 * details.
 */

jimport( 'joomla.application.component.view' );

/**
 * @package Joomla
 * @subpackage Config
 */
class DefaultComponentView extends JView
{
	/**
	 * Display the view
	 */
	function setDefaultsToolbar()
	{
		JToolBarHelper::title( JText::_( 'Hotels Manager' ), 'generic.png' );
		JToolBarHelper::publishList();
		JToolBarHelper::unpublishList();
//		JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy' );
		JToolBarHelper::deleteList();
		JToolBarHelper::editListX();
		JToolBarHelper::addNewX();
//		JToolBarHelper::preferences('com_banners', '200');
		JToolBarHelper::help( 'screen.banners' );
	}
	function display($rows, $pageNav, $lists)
	{
		DefaultComponentView::setDefaultsToolbar();
		$lang = & JFactory::getLanguage();
		$lang->load(JRequest::getVar( 'component' ));				
		//DEVNOTE: set document title
		$document = & JFactory::getDocument();
		$document->setTitle( JText::_('Hotels') );
		$ordering = ($lists['order'] == 'h.ordering');
		JHTML::_('behavior.tooltip');
		?>
		<form action="index.php?option=com_hotels" method="post" name="adminForm">
		<table>
		<tr>
			<td align="left" width="100%">
				<?php echo JText::_( 'Filter' ); ?>:
				<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($lists['search']);?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
				<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_catid').value='0';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Filter Reset' ); ?></button>
			</td>
		</tr>
		</table>
			<table class="adminlist">
			<thead>
				<tr>
					<th width="20">
						<?php echo JText::_( 'Num' ); ?>
					</th>
					<th width="20">
						<input type="checkbox" name="toggle" value=""  onclick="checkAll(<?php echo count( $rows ); ?>);" />
					</th>
					<th nowrap="nowrap" class="title">
						<?php echo JHTML::_('grid.sort',  'Hotel Name', 'h.hotel_name', @$lists['order_Dir'], @$lists['order'] ); ?>
					</th>										
					<th width="5%" nowrap="nowrap">
						<?php echo JHTML::_('grid.sort',   'Published', 'h.published', @$lists['order_Dir'], @$lists['order'] ); ?>
					</th>
					<th width="8%" nowrap="nowrap">
						<?php echo JHTML::_('grid.sort',   'Order', 'h.ordering', @$lists['order_Dir'], @$lists['order'] ); ?>
						<?php if ($ordering) echo JHTML::_('grid.order',  $rows ); ?>
					</th>					
					<th width="1%" nowrap="nowrap">
						<?php echo JHTML::_('grid.sort',   'ID', 'h.id', @$lists['order_Dir'], @$lists['order'] ); ?>
					</th>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<td colspan="13">
						<?php echo $pageNav->getListFooter(); ?>
					</td>
				</tr>
			</tfoot>
			<tbody>
			<?php
			$k = 0;
			for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];

				$row->id	= $row->id;
				$link		= JRoute::_( 'index.php?option=com_hotels&task=edit&cid[]='. $row->id );			

//				$row->published = $row->showBanner;
				$published		= JHTML::_('grid.published', $row, $i );
				$checked		= JHTML::_('grid.checkedout',   $row, $i );
				?>
				<tr class="<?php echo "row$k"; ?>">
					<td align="center">
						<?php echo $pageNav->getRowOffset($i); ?>
					</td>
					<td align="center">
						<?php echo $checked; ?>
					</td>
					<td>
						<span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit' );?>::<?php echo htmlspecialchars($row->hotel_name); ?>">						
							<a href="<?php echo $link; ?>">
								<?php echo htmlspecialchars($row->hotel_name); ?></a>						
						</span>
					</td>
					
					<td align="center">
						<?php echo $published;?>
					</td>
					<td class="order">
                    	<?php $disabled = $ordering ?  '' : 'disabled="disabled"'; ?>
						<input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />
					</td>					
					<td align="center">
						<?php echo $row->id; ?>
					</td>
				</tr>
				<?php
				$k = 1 - $k;
			}
			?>
			</tbody>
			</table>
		<input type="hidden" name="c" value="hotels" />
		<input type="hidden" name="option" value="com_hotels" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
		<input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
		</form>
		<?php     
  	}
	function setDefaultToolbar()
	{
		$task = JRequest::getVar( 'task', '', 'method', 'string');

		JToolBarHelper::title( $task == 'add' ? JText::_( 'Hotels' ) . ': <small><small>[ '. JText::_( 'New' ) .' ]</small></small>' : JText::_( 'Hotels' ) . ': <small><small>[ '. JText::_( 'Edit' ) .' ]</small></small>', 'generic.png' );
		JToolBarHelper::save( 'save' );
		JToolBarHelper::apply('apply');
		JToolBarHelper::cancel( 'cancel' );
		JToolBarHelper::help( 'screen.banners.edit' );
	}
	function hotels( & $row, & $lists ){
		DefaultComponentView::setDefaultToolbar();
		$editor =& JFactory::getEditor();
		JRequest::setVar( 'hidemainmenu', 1 );
		JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'address' );
		?>
		<script language="javascript" type="text/javascript">
		<!--
		function changeDisplayImage() {
			if (document.adminForm.imageurl.value !='') {
				document.adminForm.imagelib.src='../images/hotels/' + document.adminForm.imageurl.value;
			} else {
				document.adminForm.imagelib.src='images/blank.png';
			}
		}
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			// do field validation
			if (form.name.value == "") {
				alert( "<?php echo JText::_( 'You must provide a hotel name.', true ); ?>" );			
			} else {
				submitform( pressbutton );
			}
		}
		//-->
		</script>		
		<form action="index.php" method="post" name="adminForm">
		<div class="col100">
			<fieldset class="adminform">
				<legend><?php echo JText::_( 'Details' ); ?></legend>

				<table class="admintable">
				<tbody>
					<tr>
						<td width="20%" class="key">
							<label for="hotelname">
								<?php echo JText::_( 'Hotel Name' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="hotel_name" id="hotelname" size="50" value="<?php echo $row->hotel_name;?>" />
						</td>
					</tr>
					<tr>
						<td width="20%" class="key">
							<label for="Phone">
								<?php echo JText::_( 'Phone' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="phone" id="phone" size="50" value="<?php echo $row->phone;?>" />
						</td>
					</tr>
					<tr>
						<td width="20%" class="key">
							<label for="Phone">
								<?php echo JText::_( 'Phone1' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="phone1" id="phone1" size="50" value="<?php echo $row->phone1;?>" />
						</td>
					</tr>
					<tr>
						<td width="20%" class="key">
							<label for="Email">
								<?php echo JText::_( 'E-Mail' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="email" id="email" size="50" value="<?php echo $row->email;?>" />
						</td>
					</tr>
					<tr>
						<td width="20%" class="key">
							<label for="Email1">
								<?php echo JText::_( 'E-Mail1' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="email1" id="email1" size="50" value="<?php echo $row->email1;?>" />
						</td>
					</tr>					
					<tr>
						<td width="20%" class="key">
							<label for="Phone">
								<?php echo JText::_( 'Fax' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="fax" id="fax" size="50" value="<?php echo $row->fax;?>" />
						</td>
					</tr>
					<tr>
						<td width="20%" class="key" valign="top">
							<label for="Phone">
								<?php echo JText::_( 'Address' ); ?>:
							</label>
						</td>
						<td width="80%">
							<?php echo $editor->display( 'address',  htmlspecialchars($row->address, ENT_QUOTES), '550', '300', '60', '20', array('pagebreak', 'readmore') ) ;?>												
						</td>
					</tr>										
					<tr>
						<td width="20%" class="key">
							<label for="Rate Star">
								<?php echo JText::_( 'Star' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="star" id="star" size="50" value="<?php echo $row->star;?>" />
						</td>
					</tr>
					<tr>
						<td width="20%" class="key" valign="top">
							<label for="Website">
								<?php echo JText::_( 'Website' ); ?>:
							</label>
						</td>
						<td width="80%">							
							<input class="inputbox" type="text" name="website" id="website" size="50" value="<?php echo $row->website;?>" />
						</td>
					</tr>
					<tr>
						<td valign="top" class="key">
							<label for="imageurl">
								<?php echo JText::_( 'Hotel Image Selector' ); ?>:
							</label>
						</td>
						<td >
							<?php echo $lists['imageurl']; ?>
							<div><br />
								<?php
							if (preg_match("#swf$#i", $row->imageurl)) {
								?>
								<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" border="0" width="<?php echo $lists['width'];?>" height="<?php echo $lists['height'];?>">
									<param name="movie" value="../images/banners/<?php echo $row->imageurl; ?>"><embed src="../images/banners/<?php echo $row->imageurl; ?>" loop="false" pluginspage="http://www.macromedia.com/go/get/flashplayer" type="application/x-shockwave-flash"  width="<?php echo $lists['width'];?>" height="<?php echo $lists['height'];?>"></embed>
								</object>
								<?php
							} elseif (preg_match("#gif|jpg|png#i", $row->imageurl)) {
								?>
								<img src="../images/hotels/<?php echo $row->imageurl; ?>" name="imagelib" />
								<?php
							} else {
								?>
								<img src="images/blank.png" name="imagelib" />
								<?php
							}
							?>								
							</div>
						</td>
					</tr>					
				</tbody>
				</table>
			</fieldset>
		</div>
		<div class="clr"></div>
		<input type="hidden" name="c" value="hotels" />
		<input type="hidden" name="option" value="com_hotels" />
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="clicks" value="<?php echo $row->clicks; ?>" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="impmade" value="<?php echo $row->impmade; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
		</form>
		<?php 
	}
}
?>
